package G;

public class Example28 {
    public static void main(String[] args) {
        int[] arr = {4,1,6,3,9,8};//定义一个数组
        int max = getMax(arr);
        int min = getMin(arr);
        System.out.println("max = "+ max);
        System.out.println("min= "+min);
    }
    public static int getMax(int [] arr){
        int max=arr[0];
        for (int x = 0; x < arr.length; x++) {
            if (arr[x] > max)  {
                max = arr[x];
            }
        }
        return  max;
    }

    public static int getMin(int [] arr){
        int min=arr[0];
        for (int x = 1; x < arr.length; x++) {
            if (arr[x] < min)  {
                min = arr[x];
            }
        }
        return  min;
    }

}







